package com.cxs.plan.domain;


import com.cxs.plan.constant.HttpStatus;
import lombok.Data;

@Data
public class HttpResult {

    private int code;

    private String msg;

    private Object data;

    public HttpResult() {}

    public HttpResult(int code, String message, Object data) {
        this.code = code;
        this.msg = message;
        this.data = data;
    }

    public static HttpResult success() {
        return HttpResult.success("请求成功");
    }

    public static HttpResult success(Object data) {
        return HttpResult.success("请求成功", data);
    }

    public static  HttpResult success(String msg) { return new HttpResult(HttpStatus.SUCCESS, msg, null); }

    public static HttpResult success(String msg, Object data) { return new HttpResult(HttpStatus.SUCCESS, msg, data); }

    public static HttpResult error() {
        return HttpResult.error("请求失败");
    }

    public static HttpResult error(Object data) {
        return HttpResult.error("请求失败", data);
    }

    public static HttpResult error(String msg) {
        return new HttpResult(HttpStatus.ERROR, msg, null);
    }

    public static HttpResult error(String msg, Object data) {
        return new HttpResult(HttpStatus.ERROR, msg, data);
    }
}
